package com.mobile.collect.db;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.mobile.collect.beans.DevicePointInfo;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DEVICE_POINT_INFO".
*/
public class DevicePointInfoDao extends AbstractDao<DevicePointInfo, Long> {

    public static final String TABLENAME = "DEVICE_POINT_INFO";

    /**
     * Properties of entity DevicePointInfo.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property _ID = new Property(0, Long.class, "_ID", true, "_id");
        public final static Property ParentId = new Property(1, Long.class, "parentId", false, "PARENT_ID");
        public final static Property ScaleX = new Property(2, float.class, "scaleX", false, "SCALE_X");
        public final static Property ScaleY = new Property(3, float.class, "scaleY", false, "SCALE_Y");
        public final static Property ViewWidth = new Property(4, int.class, "viewWidth", false, "VIEW_WIDTH");
        public final static Property ViewHeight = new Property(5, int.class, "viewHeight", false, "VIEW_HEIGHT");
        public final static Property ScreenX = new Property(6, int.class, "screenX", false, "SCREEN_X");
        public final static Property ScreenY = new Property(7, int.class, "screenY", false, "SCREEN_Y");
        public final static Property PointDircetion = new Property(8, String.class, "pointDircetion", false, "POINT_DIRCETION");
        public final static Property Direction = new Property(9, int.class, "direction", false, "DIRECTION");
        public final static Property BgType = new Property(10, int.class, "bgType", false, "BG_TYPE");
        public final static Property LineType = new Property(11, int.class, "lineType", false, "LINE_TYPE");
        public final static Property LineType2 = new Property(12, String.class, "lineType2", false, "LINE_TYPE2");
        public final static Property DeviceName = new Property(13, String.class, "deviceName", false, "DEVICE_NAME");
        public final static Property AddressNo = new Property(14, String.class, "addressNo", false, "ADDRESS_NO");
        public final static Property ExpendNo = new Property(15, String.class, "expendNo", false, "EXPEND_NO");
        public final static Property Diameter = new Property(16, String.class, "diameter", false, "DIAMETER");
        public final static Property Distence = new Property(17, String.class, "distence", false, "DISTENCE");
        public final static Property Height = new Property(18, String.class, "height", false, "HEIGHT");
        public final static Property Type = new Property(19, String.class, "type", false, "TYPE");
        public final static Property TypeEn = new Property(20, String.class, "typeEn", false, "TYPE_EN");
        public final static Property ChildType = new Property(21, String.class, "childType", false, "CHILD_TYPE");
        public final static Property ChildTypeEn = new Property(22, String.class, "childTypeEn", false, "CHILD_TYPE_EN");
        public final static Property CheckHardType = new Property(23, String.class, "checkHardType", false, "CHECK_HARD_TYPE");
        public final static Property CheckHardReason = new Property(24, String.class, "checkHardReason", false, "CHECK_HARD_REASON");
        public final static Property DangerCheck = new Property(25, String.class, "dangerCheck", false, "DANGER_CHECK");
        public final static Property DangerCheckReaseon = new Property(26, String.class, "dangerCheckReaseon", false, "DANGER_CHECK_REASEON");
        public final static Property HeatPreservation = new Property(27, String.class, "heatPreservation", false, "HEAT_PRESERVATION");
        public final static Property AdditionalDes = new Property(28, String.class, "additionalDes", false, "ADDITIONAL_DES");
        public final static Property LabelName = new Property(29, String.class, "labelName", false, "LABEL_NAME");
        public final static Property DeviceCount = new Property(30, int.class, "deviceCount", false, "DEVICE_COUNT");
        public final static Property Status = new Property(31, String.class, "status", false, "STATUS");
        public final static Property CreateTime = new Property(32, long.class, "createTime", false, "CREATE_TIME");
        public final static Property IsNewPoint = new Property(33, boolean.class, "isNewPoint", false, "IS_NEW_POINT");
    }

    private Query<DevicePointInfo> devicePicInfo_PointListQuery;

    public DevicePointInfoDao(DaoConfig config) {
        super(config);
    }
    
    public DevicePointInfoDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"DEVICE_POINT_INFO\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: _ID
                "\"PARENT_ID\" INTEGER," + // 1: parentId
                "\"SCALE_X\" REAL NOT NULL ," + // 2: scaleX
                "\"SCALE_Y\" REAL NOT NULL ," + // 3: scaleY
                "\"VIEW_WIDTH\" INTEGER NOT NULL ," + // 4: viewWidth
                "\"VIEW_HEIGHT\" INTEGER NOT NULL ," + // 5: viewHeight
                "\"SCREEN_X\" INTEGER NOT NULL ," + // 6: screenX
                "\"SCREEN_Y\" INTEGER NOT NULL ," + // 7: screenY
                "\"POINT_DIRCETION\" TEXT," + // 8: pointDircetion
                "\"DIRECTION\" INTEGER NOT NULL ," + // 9: direction
                "\"BG_TYPE\" INTEGER NOT NULL ," + // 10: bgType
                "\"LINE_TYPE\" INTEGER NOT NULL ," + // 11: lineType
                "\"LINE_TYPE2\" TEXT," + // 12: lineType2
                "\"DEVICE_NAME\" TEXT," + // 13: deviceName
                "\"ADDRESS_NO\" TEXT," + // 14: addressNo
                "\"EXPEND_NO\" TEXT," + // 15: expendNo
                "\"DIAMETER\" TEXT," + // 16: diameter
                "\"DISTENCE\" TEXT," + // 17: distence
                "\"HEIGHT\" TEXT," + // 18: height
                "\"TYPE\" TEXT," + // 19: type
                "\"TYPE_EN\" TEXT," + // 20: typeEn
                "\"CHILD_TYPE\" TEXT," + // 21: childType
                "\"CHILD_TYPE_EN\" TEXT," + // 22: childTypeEn
                "\"CHECK_HARD_TYPE\" TEXT," + // 23: checkHardType
                "\"CHECK_HARD_REASON\" TEXT," + // 24: checkHardReason
                "\"DANGER_CHECK\" TEXT," + // 25: dangerCheck
                "\"DANGER_CHECK_REASEON\" TEXT," + // 26: dangerCheckReaseon
                "\"HEAT_PRESERVATION\" TEXT," + // 27: heatPreservation
                "\"ADDITIONAL_DES\" TEXT," + // 28: additionalDes
                "\"LABEL_NAME\" TEXT," + // 29: labelName
                "\"DEVICE_COUNT\" INTEGER NOT NULL ," + // 30: deviceCount
                "\"STATUS\" TEXT," + // 31: status
                "\"CREATE_TIME\" INTEGER NOT NULL ," + // 32: createTime
                "\"IS_NEW_POINT\" INTEGER NOT NULL );"); // 33: isNewPoint
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DEVICE_POINT_INFO\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, DevicePointInfo entity) {
        stmt.clearBindings();
 
        Long _ID = entity.get_ID();
        if (_ID != null) {
            stmt.bindLong(1, _ID);
        }
 
        Long parentId = entity.getParentId();
        if (parentId != null) {
            stmt.bindLong(2, parentId);
        }
        stmt.bindDouble(3, entity.getScaleX());
        stmt.bindDouble(4, entity.getScaleY());
        stmt.bindLong(5, entity.getViewWidth());
        stmt.bindLong(6, entity.getViewHeight());
        stmt.bindLong(7, entity.getScreenX());
        stmt.bindLong(8, entity.getScreenY());
 
        String pointDircetion = entity.getPointDircetion();
        if (pointDircetion != null) {
            stmt.bindString(9, pointDircetion);
        }
        stmt.bindLong(10, entity.getDirection());
        stmt.bindLong(11, entity.getBgType());
        stmt.bindLong(12, entity.getLineType());
 
        String lineType2 = entity.getLineType2();
        if (lineType2 != null) {
            stmt.bindString(13, lineType2);
        }
 
        String deviceName = entity.getDeviceName();
        if (deviceName != null) {
            stmt.bindString(14, deviceName);
        }
 
        String addressNo = entity.getAddressNo();
        if (addressNo != null) {
            stmt.bindString(15, addressNo);
        }
 
        String expendNo = entity.getExpendNo();
        if (expendNo != null) {
            stmt.bindString(16, expendNo);
        }
 
        String diameter = entity.getDiameter();
        if (diameter != null) {
            stmt.bindString(17, diameter);
        }
 
        String distence = entity.getDistence();
        if (distence != null) {
            stmt.bindString(18, distence);
        }
 
        String height = entity.getHeight();
        if (height != null) {
            stmt.bindString(19, height);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(20, type);
        }
 
        String typeEn = entity.getTypeEn();
        if (typeEn != null) {
            stmt.bindString(21, typeEn);
        }
 
        String childType = entity.getChildType();
        if (childType != null) {
            stmt.bindString(22, childType);
        }
 
        String childTypeEn = entity.getChildTypeEn();
        if (childTypeEn != null) {
            stmt.bindString(23, childTypeEn);
        }
 
        String checkHardType = entity.getCheckHardType();
        if (checkHardType != null) {
            stmt.bindString(24, checkHardType);
        }
 
        String checkHardReason = entity.getCheckHardReason();
        if (checkHardReason != null) {
            stmt.bindString(25, checkHardReason);
        }
 
        String dangerCheck = entity.getDangerCheck();
        if (dangerCheck != null) {
            stmt.bindString(26, dangerCheck);
        }
 
        String dangerCheckReaseon = entity.getDangerCheckReaseon();
        if (dangerCheckReaseon != null) {
            stmt.bindString(27, dangerCheckReaseon);
        }
 
        String heatPreservation = entity.getHeatPreservation();
        if (heatPreservation != null) {
            stmt.bindString(28, heatPreservation);
        }
 
        String additionalDes = entity.getAdditionalDes();
        if (additionalDes != null) {
            stmt.bindString(29, additionalDes);
        }
 
        String labelName = entity.getLabelName();
        if (labelName != null) {
            stmt.bindString(30, labelName);
        }
        stmt.bindLong(31, entity.getDeviceCount());
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(32, status);
        }
        stmt.bindLong(33, entity.getCreateTime());
        stmt.bindLong(34, entity.getIsNewPoint() ? 1L: 0L);
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, DevicePointInfo entity) {
        stmt.clearBindings();
 
        Long _ID = entity.get_ID();
        if (_ID != null) {
            stmt.bindLong(1, _ID);
        }
 
        Long parentId = entity.getParentId();
        if (parentId != null) {
            stmt.bindLong(2, parentId);
        }
        stmt.bindDouble(3, entity.getScaleX());
        stmt.bindDouble(4, entity.getScaleY());
        stmt.bindLong(5, entity.getViewWidth());
        stmt.bindLong(6, entity.getViewHeight());
        stmt.bindLong(7, entity.getScreenX());
        stmt.bindLong(8, entity.getScreenY());
 
        String pointDircetion = entity.getPointDircetion();
        if (pointDircetion != null) {
            stmt.bindString(9, pointDircetion);
        }
        stmt.bindLong(10, entity.getDirection());
        stmt.bindLong(11, entity.getBgType());
        stmt.bindLong(12, entity.getLineType());
 
        String lineType2 = entity.getLineType2();
        if (lineType2 != null) {
            stmt.bindString(13, lineType2);
        }
 
        String deviceName = entity.getDeviceName();
        if (deviceName != null) {
            stmt.bindString(14, deviceName);
        }
 
        String addressNo = entity.getAddressNo();
        if (addressNo != null) {
            stmt.bindString(15, addressNo);
        }
 
        String expendNo = entity.getExpendNo();
        if (expendNo != null) {
            stmt.bindString(16, expendNo);
        }
 
        String diameter = entity.getDiameter();
        if (diameter != null) {
            stmt.bindString(17, diameter);
        }
 
        String distence = entity.getDistence();
        if (distence != null) {
            stmt.bindString(18, distence);
        }
 
        String height = entity.getHeight();
        if (height != null) {
            stmt.bindString(19, height);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(20, type);
        }
 
        String typeEn = entity.getTypeEn();
        if (typeEn != null) {
            stmt.bindString(21, typeEn);
        }
 
        String childType = entity.getChildType();
        if (childType != null) {
            stmt.bindString(22, childType);
        }
 
        String childTypeEn = entity.getChildTypeEn();
        if (childTypeEn != null) {
            stmt.bindString(23, childTypeEn);
        }
 
        String checkHardType = entity.getCheckHardType();
        if (checkHardType != null) {
            stmt.bindString(24, checkHardType);
        }
 
        String checkHardReason = entity.getCheckHardReason();
        if (checkHardReason != null) {
            stmt.bindString(25, checkHardReason);
        }
 
        String dangerCheck = entity.getDangerCheck();
        if (dangerCheck != null) {
            stmt.bindString(26, dangerCheck);
        }
 
        String dangerCheckReaseon = entity.getDangerCheckReaseon();
        if (dangerCheckReaseon != null) {
            stmt.bindString(27, dangerCheckReaseon);
        }
 
        String heatPreservation = entity.getHeatPreservation();
        if (heatPreservation != null) {
            stmt.bindString(28, heatPreservation);
        }
 
        String additionalDes = entity.getAdditionalDes();
        if (additionalDes != null) {
            stmt.bindString(29, additionalDes);
        }
 
        String labelName = entity.getLabelName();
        if (labelName != null) {
            stmt.bindString(30, labelName);
        }
        stmt.bindLong(31, entity.getDeviceCount());
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(32, status);
        }
        stmt.bindLong(33, entity.getCreateTime());
        stmt.bindLong(34, entity.getIsNewPoint() ? 1L: 0L);
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public DevicePointInfo readEntity(Cursor cursor, int offset) {
        DevicePointInfo entity = new DevicePointInfo( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // _ID
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // parentId
            cursor.getFloat(offset + 2), // scaleX
            cursor.getFloat(offset + 3), // scaleY
            cursor.getInt(offset + 4), // viewWidth
            cursor.getInt(offset + 5), // viewHeight
            cursor.getInt(offset + 6), // screenX
            cursor.getInt(offset + 7), // screenY
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pointDircetion
            cursor.getInt(offset + 9), // direction
            cursor.getInt(offset + 10), // bgType
            cursor.getInt(offset + 11), // lineType
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // lineType2
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // deviceName
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // addressNo
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // expendNo
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // diameter
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // distence
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // height
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // type
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // typeEn
            cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // childType
            cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // childTypeEn
            cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // checkHardType
            cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // checkHardReason
            cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // dangerCheck
            cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26), // dangerCheckReaseon
            cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27), // heatPreservation
            cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28), // additionalDes
            cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // labelName
            cursor.getInt(offset + 30), // deviceCount
            cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31), // status
            cursor.getLong(offset + 32), // createTime
            cursor.getShort(offset + 33) != 0 // isNewPoint
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, DevicePointInfo entity, int offset) {
        entity.set_ID(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setParentId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setScaleX(cursor.getFloat(offset + 2));
        entity.setScaleY(cursor.getFloat(offset + 3));
        entity.setViewWidth(cursor.getInt(offset + 4));
        entity.setViewHeight(cursor.getInt(offset + 5));
        entity.setScreenX(cursor.getInt(offset + 6));
        entity.setScreenY(cursor.getInt(offset + 7));
        entity.setPointDircetion(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setDirection(cursor.getInt(offset + 9));
        entity.setBgType(cursor.getInt(offset + 10));
        entity.setLineType(cursor.getInt(offset + 11));
        entity.setLineType2(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setDeviceName(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setAddressNo(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setExpendNo(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setDiameter(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setDistence(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setHeight(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setType(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setTypeEn(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
        entity.setChildType(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
        entity.setChildTypeEn(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22));
        entity.setCheckHardType(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23));
        entity.setCheckHardReason(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24));
        entity.setDangerCheck(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25));
        entity.setDangerCheckReaseon(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26));
        entity.setHeatPreservation(cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27));
        entity.setAdditionalDes(cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28));
        entity.setLabelName(cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29));
        entity.setDeviceCount(cursor.getInt(offset + 30));
        entity.setStatus(cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31));
        entity.setCreateTime(cursor.getLong(offset + 32));
        entity.setIsNewPoint(cursor.getShort(offset + 33) != 0);
     }
    
    @Override
    protected final Long updateKeyAfterInsert(DevicePointInfo entity, long rowId) {
        entity.set_ID(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(DevicePointInfo entity) {
        if(entity != null) {
            return entity.get_ID();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(DevicePointInfo entity) {
        return entity.get_ID() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "pointList" to-many relationship of DevicePicInfo. */
    public List<DevicePointInfo> _queryDevicePicInfo_PointList(Long parentId) {
        synchronized (this) {
            if (devicePicInfo_PointListQuery == null) {
                QueryBuilder<DevicePointInfo> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.ParentId.eq(null));
                devicePicInfo_PointListQuery = queryBuilder.build();
            }
        }
        Query<DevicePointInfo> query = devicePicInfo_PointListQuery.forCurrentThread();
        query.setParameter(0, parentId);
        return query.list();
    }

}
